﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

using iDB_Sharp;

namespace iDB_Sharp.Sample
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		DB db;
		DataElement de;
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
			
			testSave();
//			testLoad();
		}
		
		private void testSave()
		{
			de = new DataElement();
			de.Data.Add(2);
			de.Data.Add("Hallo");
			de.Data.Add(23);
			db = new DB(de, "Test", "E:\\iDB");
			db.Commit = true;
			db.CommitRate = 2;
			de.Data.Add("Tet");
			if(!db.addElement(de))
				this.textBox1.Text = "Erstes Add fehlerhaft";
			else
				this.textBox1.Text = "Erstes Add korrekt";
			de = new DataElement();
			de.Data.Add(3);
			de.Data.Add("Test");
			de.Data.Add(24);
			if(!db.addElement(de))
				this.textBox2.Text = "Zweites Add fehlerhaft";
			else
				this.textBox2.Text = "Zweites Add korrekt";
//			DB.saveDB(db, true);
			db.exportToCSV("E:\\iDB");
		}
		
		private void testLoad()
		{
			db = DB.loadDB("E:\\iDB\\Test.idb");			
		}
	}
}
